##
# Copyright (c) 2012, Ken Anderson
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without modification, 
# are permitted provided that the following conditions are met:
# 
# 1. Redistributions of source code must retain the above copyright notice, 
#    this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, 
#    this list of conditions and the following disclaimer in the documentation 
#    and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##

# Compiler settings
set(CMAKE_BUILD_TYPE Debug)

set(h264_HEADERS block.h cavlc.h cavlc_tables.h common.h coretrans.h h264.h input.h intra_pred.h main.h mbmodes.h mocomp.h mode_pred.h nal.h params.h perf.h residual.h slice.h slicehdr.h)
set(h264_SOURCE common.c coretrans.c nal.c cavlc.c params.c slicehdr.c slice.c mbmodes.c residual.c block.c mode_pred.c intra_pred.c mocomp.c perf.c input.c in_file.c main.c)

# Library
include_directories( )
set(LIBS mediaClLib) #Pay attention to order
add_library (h264lib ${h264_SOURCE} ${h264_HEADERS})

# Tests
include_directories( . )

add_executable( coretrans-test coretrans-test.c )
add_executable( mbmodes-test   mbmodes-test.c )
add_executable( nal-test       nal-test.c )
add_executable( params-test    params-test.c )
add_executable( perf-test      perf-test.c )
add_executable( slicehdr-test  slicehdr-test.c )
add_executable( main-test      main-test.c )

target_link_libraries(coretrans-test h264lib ${LIBS})
target_link_libraries(mbmodes-test   h264lib ${LIBS})
target_link_libraries(nal-test       h264lib ${LIBS})
target_link_libraries(params-test    h264lib ${LIBS})
target_link_libraries(perf-test      h264lib ${LIBS})
target_link_libraries(slicehdr-test  h264lib ${LIBS})
target_link_libraries(main-test      h264lib ${LIBS})

# Create sub-folder
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(TARGET h264lib         PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET coretrans-test  PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET mbmodes-test    PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET nal-test        PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET params-test     PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET perf-test       PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET slicehdr-test   PROPERTY FOLDER "h264")
SET_PROPERTY(TARGET main-test       PROPERTY FOLDER "h264")
